Skip to content

fix: resolve failing tests and type errors across api and shared packages#61

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2430-1781683676
Open

fix: resolve failing tests and type errors across api and shared packages#61
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2430-1781683676

Conversation

@stooit

@stooit stooit commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all tsc --noEmit type errors in the Bun + Hono TypeScript monorepo. Final state: 22 tests pass, 0 fail; bunx tsc --noEmit clean.

Bugs spanned both the api and shared packages.

Fixes

  • Auth middleware (packages/api/src/middleware/auth.ts) — case-sensitivity bug: POST was listed in lowercase in the public-methods check, but Hono's c.req.method is always uppercase (RFC 7231), so POST /users incorrectly required a token. Added POST to the uppercase public-methods list. Also switched the token lookup to Bun.env so it type-checks without @types/node.
  • Shared types (packages/shared/src/types.ts)User.userName renamed to username to match the field name already used by db.ts, the users route, and the test suite. The type was the outlier; aligned it to the actual contract.
  • Users route (packages/api/src/routes/users.ts) — added the missing badRequest import from ../lib/errors, fixing a runtime failure on the 400 validation path.
  • Pagination (packages/shared/src/utils/pagination.ts) — implemented the paginate() stub: page slicing, total, totalPages (Math.ceil), correct page/pageSize fields, and edge cases for empty input and out-of-range pages (returns empty data).
  • tsconfig.json — ensured Bun/process types resolve without adding any dependency.

Verification

  • bun test -> 22 pass / 0 fail
  • bunx tsc --noEmit -> clean (exit 0)
  • Independent review pass confirmed: no test files modified, no dependencies added, no behaviour weakened.

Assumptions

  • The canonical field name is username (lowercase), per the tests and existing db/route code.
  • Bun.env/process.env equivalence in the Bun runtime is relied upon so the fix needs no @types/node dependency.

…ages

- auth middleware: include POST in public methods (HTTP methods are
  uppercase) and read token via Bun.env to satisfy tsc
- shared types: rename User.userName -> username to match the contract
  used by db, routes, and tests
- users route: import missing badRequest helper from lib/errors
- shared: implement paginate() stub with correct slicing, total,
  totalPages, and out-of-range/empty edge cases
- tsconfig: ensure bun/process types resolve without new deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant